package uk.co.accolade.clash.core.message;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import uk.co.accolade.clash.core.ClashFilePath;
import uk.co.accolade.clash.core.UserChanges;
import static uk.co.accolade.clash.core.UserChangesHasFilePath.hasFilePath;
import uk.co.accolade.clash.core.Username;

public class MessageTestUtils {

    public static UserChanges parse( String message ) {
        MessageParser parser = MessageParserFactory.getParserForMessage( message );
        return parser.parse( message );
    }

    public static void assertChanges( UserChanges changes, Username username, ClashFilePath... filepaths ) {
        assertThat(changes.getUsername(), is( username ) );
        for( ClashFilePath filePath : filepaths ) {
            assertThat(changes, hasFilePath( filePath ) );
        }
    }
}